﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using WMS.Infrastructure;
using MediatR;
using System.Threading.Tasks;
using WMS.Common;
using WMS.Domain;
using System.Collections.Generic;
using WMS.Api.Application.Commands;

namespace WMS.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ProductmarginsController : ControllerBase
    {
        private readonly IMediator _mediator;

        public ProductmarginsController(IMediator mediator)
        {
            _mediator = mediator;
        }

        /// <summary>
        /// 查询产品利润数据（带分页）
        /// </summary>
        /// <param name="team">团队</param>
        /// <param name="outboundCode">出库单号</param>
        /// <param name="time">时间</param>
        /// <param name="pageIndex">页码，默认为1</param>
        /// <param name="pageSize">每页大小，默认为10</param>
        /// <returns>分页结果</returns>
        [HttpGet]
        public async Task<PagingResult<List<Productmargins>>> QueryProductmargins([FromQuery]QueryProductmarginsCommand request)
        {
           return await _mediator.Send(request);
        }

        /// <summary>
        /// 库存出入库
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> CreateInventoryModel(CreateInventoryModelCommand request)
        {
            return await _mediator.Send(request);
        }
    }
}
